﻿//This filter is tested and seems to work correctly

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace LowLevelGraphics.Filter
{
    /// <summary>
    /// Edge detection Filter
    /// This calculates the derivation
    /// The Laplace transform is a technique 
    /// for analyzing these special systems when 
    /// the signals are continuous. 
    /// The z-transform is a similar technique used in the discrete case.
    /// </summary>
    public class EmbossLaplacian : BaseImageFilter
    {
        /// <summary>
        /// default constructor
        /// </summary>
        public EmbossLaplacian()
        {
        }

        /// <summary>
        /// Used by clone to create a deep copy
        /// </summary>
        /// <param name="_embossLaplacian"></param>
        internal EmbossLaplacian(EmbossLaplacian _embossLaplacian)
        {
        }

        /// <summary>
        /// Executes this filter
        /// </summary>
        /// <param name="_bitmap"></param>
        /// <returns></returns>
        public override UnsafeBitmap Execute(UnsafeBitmap _bitmap)
        {
            CConvMatrix Matrix = new CConvMatrix();
            Matrix.SetAll(-1);
            Matrix.TopMid = Matrix.MidLeft = Matrix.MidRight = Matrix.BottomMid = 0;
            Matrix.Pixel = 4;
            Matrix.Offset = 127;

            new Convolution3x3(Matrix).Execute(_bitmap);
            return _bitmap;
        }

        /// <summary>
        /// used to create a deep copy
        /// </summary>
        /// <returns></returns>
        public override object Clone()
        {
            return new EmbossLaplacian(this);
        }
    }
}
